<!DOCTYPE html>
<html lang="zh-CN" style="font-size: 34.722px;"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <title>确认订单</title>
    <link rel="stylesheet" type="text/css" href="/css/shop/base.css">
    <link rel="stylesheet" type="text/css" href="/css/shop/confirm.css">
    <link rel="stylesheet" type="text/css" href="/css/shop/mui.min.css">
    <link rel="stylesheet" type="text/css" href="/css/shop/loaders.min.css">
    <link rel="stylesheet" type="text/css" href="/css/shop/loading.css">
	<script src="/js/shop/rem.js"></script>
    <script src="/js/shop/jquery.min.js" type="text/javascript"></script>
	<link rel="stylesheet" href="/js/plugins/dialog2/dialog.css" />
	<script src="/js/plugins/dialog2/dialog.min.js"></script>
	<script src="/js/plugins/jrender/jrender.min.js"></script>
	<script type="text/javascript">
		$(function(){
			$(".loading").addClass("loader-chanage")
			$(".loading").fadeOut(300)
            var shopCarId = window.sessionStorage.getItem("shopCarIds")[0];
            // 查询对应要结算的商品信息
            $.get('/items/confirm',{shopCarId:shopCarId},function (data) {
                $('.confirmInfo').renderValues({list:data},{
                    // 保存用户的姓名
                    bridge: function (item, value) {
						$(item).attr("data-name",value);
                    },
                    setValue:function (item, value) {
                        var name = $(item).parent().data('name');
                        var split = value.split(',');
                       	$(item).html(split[0] + " " + name + " " + split[1]);
                    },
                    setCredit:function (item, value) {
						$(item).html(value);
						var price = $(item).parent().parent().parent().parent().prev().find('.price').html();
                        $('#totalCredits').html(value*price);
                    }
				});
                // 商品加购物车数量
                var count = $('#count').text();
                $('#down').click(function () {
                    if(count > 1){
                        count--;
                    }else{
                        count = 1;
                    }
                    $('#count').text(count);
                    setTotal(this);
                });

                $('#plus').click(function () {
                    count++;
                    $('#count').text(count);
                    setTotal(this);
                });

                // 动态计算积分
                function setTotal(ele) {
                    // 获取数量
                    var count = $(ele).parent().find('#count').text();
                    var price = $(ele).parent().parent().parent().parent().prev().find('.price').html()
                    // 计算积分并赋值
                    $('#totalCredits').html(count*price);
                }
                // 提交生成订单

                $('.account').click(function () {
                    var user = JSON.parse(window.sessionStorage.getItem("user"));
                    // 取参数
                    var userId = user.id;
                    var itemId = data.item.id;
                    var mark = $('input[name=mark]').val();
                    var addressId = data.address.id;
                    var count = $('#count').html();
					var receipt = null;
                    var need = $('.receipt input:radio:checked').next().next().html();
                    if(need == "需要发票"){
                        receipt = 1;
                    } else if(need == "不需要发票"){
                        receipt = 0;
                    }
                    var params = data.params;
                    	$.post('/orders/commit',{"user.id":userId,"item.id":itemId,mark:mark,"address.id":addressId,count:count,receipt:receipt,itemparams:params,"shopcar.id":shopCarId},function (data) {
                         if(data.success){
                             $(document).dialog({
                                 type : 'confirm',
                                 style: 'ios',
                                 titleText: '支付信息',
                                 content: '支付成功',
                                 buttons: [
                                     {
                                         name: '去首页',
                                         callback: function() {
                                             window.location.href = '/mine/shop.html';
                                         }
                                     },
                                     {
                                         name: '查看订单',
                                         callback: function() {
                                             window.location.href = '/mine/order.html';
                                         }
                                     }
                                 ]
                             });
						 }
                     });
                });
            });

		})
	</script>
</head>
<!--loading页开始-->
<body><div class="loading loader-chanage" style="display: none;">
	<div class="loader">
        <div class="loader-inner pacman">
          <div></div>
          <div></div>
          <div></div>
          <div></div>
          <div></div>
        </div>
	</div>
</div>
<!--loading页结束-->
	
		<!--header star-->
		<header class="mui-bar mui-bar-nav" id="header">
			<a class="btn" href="javascript:history.go(-1)">
	            <i class="iconfont icon-fanhui"></i>
	        </a>
	        <div class="top-sch-box top-sch-boxtwo flex-col">
	                      确认订单
	        </div>
	    </header>
	    <!--header end-->
<div class="confirmInfo">
	    <div class="warp warptwo clearfloat">
	    	<div class="confirm clearfloat">
	    		<div class="add clearfloat box-s">
	    			<a href="#">
		    			<div class="left clearfloat fl">
		    				<i class="iconfont icon-dizhi1"></i>
		    			</div>
		    			<div class="middle clearfloat fl" data-name="" render-fun="bridge" render-key="list.user.nickName">
		    				<p class="tit" render-fun="setValue" render-key="list.address.userInfoDisplay">

		    				</p>
		    				<p class="fu-tit over2" render-html="list.address.adressInfo">

		    				</p>
		    			</div>
		    			<div class="left clearfloat fr">
		    				<i class="iconfont icon-jiantou1"></i>
		    			</div>
	    			</a>
	    		</div>
	    		<div class="lie clearfloat">
					<a href="#">
						<div class="tu clearfloat fl">
							<img render-src="list.item.imageUrl">
						</div>
					</a>
					<div class="right clearfloat fl">
						<a href="#">
							<p class="tit over" render-html="list.item.description"></p>
							<p class="fu-tit" render-html="list.params"></p>
						</a>
						<div class="xia clearfloat">
							<a href="#">
								<p class="jifen fl over price" render-html="list.item.price"></p>
							</a>
							<span class="fr db">×1</span>
						</div>
					</div>
				</div>
				<div class="gmshu clearfloat box-s fl">
					<div class="gcontent clearfloat">
						<p class="fl">购买数量</p>
			     		<div class="you clearfloat fr">
			     			<ul>
			     				<li id="down"><img src="/img/shop/jian.jpg"></li>
			     				<li id="count" render-fun="setCredit" render-key="list.count"></li>
			     				<li id="plus"><img src="/img/shop/jia.jpg"></li>
			     			</ul>
			     		</div>
					</div>		     		
		     	</div>
		     	<div class="gmshu gmshutwo clearfloat box-s fl">
					<div class="gcontent clearfloat">
						<p class="fl">配送方式</p>
			     		<div class="you clearfloat fr">
			     			<span id="method">快递 免邮</span>
			     			<i class="iconfont icon-jiantou1"></i>
			     		</div>
					</div>		     		
		     	</div>
		     	<div class="gmshu gmshutwo clearfloat box-s fl">
					<div class="gcontent clearfloat receipt">
						<p class="fl">发票信息</p>
			     		<div class="you clearfloat fr">
			     			<div class="xuan clearfloat">
			     				<div class="radiotwo"> 
								    <label>
								        <input type="radio" name="fapiao" value="" checked="">
								        <div class="option"></div>
								        <span class="opt-text">需要发票</span>
								    </label>
								</div>
			     			</div>
		    				<div class="xuan clearfloat">
			     				<div class="radiotwo"> 
								    <label>
								        <input type="radio" name="fapiao" value="">
								        <div class="option"></div>
								        <span class="opt-text">不需要发票</span>
								    </label>
								</div>
			     			</div>
			     		</div>
					</div>		     		
		     	</div>
		     	<div class="gmshu gmshuthree clearfloat box-s fl">
					<div class="gcontent clearfloat">
						<p class="fl">买家留言</p>
			     		<div class="you clearfloat fl">
			     			<input type="text" name="mark" id="" value="" class="text" placeholder="选填 对本次交易需求给商家留言">
			     		</div>
					</div>		     		
		     	</div>
		     	<div class="gmshu clearfloat box-s fl">
					<p class="fr">共1件商品   合计<samp>100000积分</samp></p>	     		
		     	</div>
		     	
	    	</div>
	    </div>	    
	    
		<!--settlement star-->
	    <div class="settlement clearfloat">
	    	<div class="zuo clearfloat fl box-s">
	    		共<span totalCount>1</span>件  总积分：<span id="totalCredits"></span>
	    	</div>
	    	<a href="javascript:;" class="fl db account">
	    		提交订单
	    	</a>
	    </div>
	    <!--settlement end-->
</div>
			<!--footer star-->
			<footer class="page-footer fixed-footer" id="footer">
				<ul>
					<li>
						<a href="/mine/shop.html">
							<i class="iconfont icon-shouye"></i>
							<p>首页</p>
						</a>
					</li>
					<li>
						<a href="/mine/itemcatalog.html">
							<i class="iconfont icon-icon04"></i>
							<p>分类</p>
						</a>
					</li>
					<li class="active">
						<a href="/mine/shopcar.html">
							<i class="iconfont icon-gouwuche"></i>
							<p>购物车</p>
						</a>
					</li>
					<li>
						<a href="/mine/profiles.html">
							<i class="iconfont icon-yonghuming"></i>
							<p>我的</p>
						</a>
					</li>
				</ul>
			</footer>
<!--footer end-->
	
	

</body></html>